/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-06
 * Time: 15:54
 */
public class Demo10 {
    public static boolean isFinished = false;
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while(!isFinished) {//内部类能够访问到外部类的成员变量
                System.out.println("hello thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();
        for (int i = 0; i < 3; i++) {
            System.out.println("hello main!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        isFinished = true;
    }
}
